Skip to content

Conversation

@gitducheng
Copy link

fix: not mounted on DragStart.

@sibartlett
Copy link

Can we get this merged and released?

@Villadshammershoi
Copy link

Considering the simplicity of this fix, how come it's not merged yet?

@rsshilli
Copy link

rsshilli commented May 1, 2025

I worked around this problem (in my React class, not function) by changing code that looked like this:

<Draggable nodeRef={this.myRef}>
  <div className="quick-panel-left-border" ref={(thisDiv) => (this.myRef = thisDiv)}>
   ...
  </div>
</Draggable>

to this:

<Draggable nodeRef={this.myRef}>
  <div className="quick-panel-left-border" ref={this.myRef}>
   ...
  </div>
</Draggable>

I just changed the ref={} function. I don't know why that would make a difference, but it did.

@STRML
Copy link
Collaborator

STRML commented Dec 31, 2025

Closing this PR as stale. While this DraggableCore mounting fix received community interest, the PR has been open since 2022 without being merged. The codebase has been updated to support React 19 and uses the nodeRef pattern. If this issue persists, please open a fresh PR against the current codebase. Thank you for the contribution!

@STRML STRML closed this Dec 31, 2025
@STRML
Copy link
Collaborator

STRML commented Dec 31, 2025

Retrospective note: This PR contains a legitimate one-line bug fix. The change from this.props?.nodeRef to this.props?.nodeRef?.current correctly handles the case where nodeRef is provided but nodeRef.current is still null during initial render/mounting.

The fix is simple and correct. If anyone wants to re-implement this against the current React 19-compatible codebase, this is the core change needed:

// Before (buggy):
return this.props?.nodeRef ? this.props?.nodeRef?.current : ReactDOM.findDOMNode(this);
// After (fixed):
return this.props?.nodeRef?.current ? this.props?.nodeRef?.current : ReactDOM.findDOMNode(this);

@STRML
Copy link
Collaborator

STRML commented Dec 31, 2025

Reopening - this is a legitimate bug fix worth implementing.

@STRML STRML reopened this Dec 31, 2025
@STRML
Copy link
Collaborator

STRML commented Dec 31, 2025

Closing - Handled Differently in React 19 Update

The codebase has been updated for React 19 compatibility. The findDOMNode() method now:

  1. Returns nodeRef.current if nodeRef is provided
  2. Falls back to ReactDOM.findDOMNode() only if available (React 18 and earlier)
  3. Logs a warning if neither is available (React 19+ without nodeRef)

The specific bug this PR addressed (returning null during initial mount) is now handled by requiring nodeRef in React 19. If nodeRef.current is null, it indicates a user setup issue rather than a library bug.

Thank you for identifying this issue - it helped inform the React 19 migration!

@STRML STRML closed this Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants